package main

type Node struct {
	Val      int
	Children []*Node
}

type MyNode struct {
	tree  *Node
	depth int
}

func maxDepth(root *Node) int {
	if root == nil {
		return 0
	}
	stack := []*MyNode{
		{tree: root, depth: 1},
	}
	depth := 0
	for len(stack) > 0 {
		top := stack[len(stack)-1]
		stack = stack[0 : len(stack)-1]
		if top.depth > depth {
			depth = top.depth
		}
		if top != nil && top.tree != nil {
			for _, child := range top.tree.Children {
				stack = append(stack, &MyNode{child, top.depth + 1})
			}
		}
	}
	return depth
}

func main() {

}
